import React, { Component } from 'react'
import PubSub from 'pubsub-js'
import Son from './Son'

export default class Far extends Component {
  componentDidMount() {
    // id是当前订阅的id.类似于定时器的id
    this.id = PubSub.subscribe('richWomen', (topic, data) => {
      console.log('far接收到富婆话题了', topic, data)
    })
  }

  componentWillUnmount() {
    PubSub.unsubscribe(this.id)
  }
  render() {
    return (
      <div>
        Far
        <hr />
        <Son></Son>
      </div>
    )
  }
}
